#include <iostream>
#include <vector>

using namespace std;

class Solution {
public:
    /**
     * 代码中的类名、方法名、参数名已经指定，请勿修改，直接返回方法规定的值即可
     *
     * 
     * @param grid int整型vector<vector<>> 
     * @return int整型
     */
    int maxValue(vector<vector<int> >& grid) {
        // write code here
        // 这个其实就很简单了
        int n = grid.size(), m = grid[0].size();
        vector<vector<int>> r(n + 1, vector<int>(m + 1));
        for (int i = 1; i <= n; i++){
            for (int j = 1; j <= m; j++){
                r[i][j] = max(r[i - 1][j], r[i][j - 1]) + grid[i - 1][j - 1];
            }
        }
        return r[n][m];
    }
};

// the beauty of symmetry